Automation of an atomic force microscope via Arduino

Graphical abstract

on solid substrates that are barely or not even visible with electron microscopy due to the very thin size, in the few nanometers. Moreover, the AFM provides a quantitative and precise measurement of the height of the features in the image with precision below one nanometer. The substrate does not need to be metal coated, as it is the case in electron microscopy (see Fig. 1), and it can measure in interesting conditions such as with the sample immersed in liquid, especially interesting for biological samples. The AFM equipment is usually sold in the half million dollars range for standard units, with just a few brands to choose from, and therefore it becomes very expensive to upgrade old but reliable units already working in our labs. We show that it is possible to motorize a 20 years old manual Dimension 3000 AFM via Arduino with sub-micron size positioning accuracy. Such automations are very valuable as experimentalists [3]. Furthermore, with some tweaking it is also possible to automate the measurements such that dozens of AFM images can be taken in an unattended way sampling different positions over the same substrate. It is worth mentioning that although the equipment is 20 years old, it was luckily upgraded to Windows XP several years ago. A quotation for an upgrade to the latest software and a new PC unit was within 10000 $. Such quotation just for the PC unit points out the difficulty for many laboratories to partially upgrade these equipment. Our automation, under 60 $, offers a huge difference in cost to labs compared to acquiring new equipment with similar capabilities, both helping the majority of laboratories that do not have the required funds, and giving a second life to reliable equipment adapted to the new necessities in Science.

Hardware description
The hardware is described in Fig. 2, and it is comp7811osed of a 20 years old manual Dimension 3000 AFM, a motorization via 3D printed plastic gears and NEMA 17 stepper motors, and an Arduino Leonardo to control this motorization in a manual way via an inbuilt keyboard with joystick. This Arduino control unit is also used to automate the acquisition and movement by emulating a keyboard when connected via USB to a PC, a feature available in Arduino Leonardo. The gears ratio and the microstepping result in individual steps of 0.18 ± 0.01 μm. Since the PC unit is obsolete, we were not able to connect to the serial port of the Arduino to exchange the necessary commands. Instead, it is possible to control all the necessary steps within the AFM commercial software by keyboard shortcuts emulated by the Arduino Leonardo, that is connected via USB to the PC unit. Moreover, the acquisition process involves the probe tip of the AFM approaching physically the sample until it senses that touched it, by measuring the deflection of the probe tip. This process takes different amounts of time for each image taken, and the only feedback coming from the AFM when the acquisition begins is a beep coming from a buzzer attached to a dedicated PCI card. Once the acquisition starts, the time it takes to acquire it is known from the AFM setup and is an input parameter in the Arduino control unit. Thus, with the emulated keyboard from the Arduino Leonardo to control the PC unit, and the feedback through listening to the buzzer to know when the image starts to be acquired, we were able to implement fully unattended automation in which it is possible to take an arbitrary number of images on a sample spaced an arbitrary amount between them. Thus, this low cost motorization and automation extends the features and life of a 20 years old but reliable AFM equipment to scan samples in multiple places in an unattended way.
• It extends the life and capabilities of a 20 years old but reliable Atomic Force Microscope by motorizing it with sub-micron positioning accuracy and by fully unattended automation of the measurements. • The cost is negligible in comparison to upgrading to a newer Atomic Force Microscope with similar capabilities.
• It can be easily programmed in Arduino to extend the capabilities respect to commercial units thanks to the Open Source firmware and hardware.

Design files
The gears were designed with the OpenSCAD Herringbone Wade's Gears Script: [4] (see Fig. 3 and 3D printed with polylactic acid (PLA) plastic filament with a Creality Ender 3 printer. The only parameters tweaked in order to fit the big gears in the AFM were the following: gear2_shaft_diameter = 4.2 mm, gear2_shaft_height = 17.5 mm, gear2_middle_diameter = 39 mm, gear2_middle_rounding = 0.01 mm, gear2_nut_diameter = 15 mm, gear2_nut_sunk = 4 mm, and gear2_decoration_solid = true. The OpenSCAD source file and the.stl are available in a Zenodo repository [1].
Electronics: The electronic layout is the one in Fig. 4. Software and firmware: Available in a Zenodo repository [1]. The library LCD I2C needs to be installed in Arduino from the library manager, and the 5IOKeypad Arduino Library can be installed manually from the Sourceforge webpage [5].

Fig. 2.
Image of the AFM showing a detail of the motorization, the Arduino based control with automated acquisition, and the PC unit which Arduino interfaces as a keyboard to emulate keyboard shortcuts, and to listen to the beep when the AFM starts the acquisition, the only feedback available from the AFM.  Demonstration AFM.mp4 -video provides a description of how to perform automated measurement. Gears Automation AFM Arduino.stlfile provides 3D model to print the gears. Gears Automation AFM Arduino.scad -OpenSCAD file providing the script for generating the 3D gears. involute gears.scad -OpenSCAD file providing the script for generating parametric involute bevel and spur gears by GregFrost. teardrop.scad -OpenSCAD file providing the script for generating a teardrop shape at the appropriate angle to prevent overhangs greater than 45 degrees. Automation AFM.ino -Arduino code for control unit. Parts marked with an asterisk were 3D printed on PLA, and estimated at 42 $/kg.

Build instructions
While this project would benefit from creating a dedicated shield for Arduino, it is still a work in progress, and therefore the electronic schematics in Fig. 4 were mounted on perfboard for the stepper motor drivers and common 5 V, 12 V and ground lines, and everything was encased in a plastic box for protection of the electronics as it can be seen in Fig. 5. As explained in the Hardware Description, the dedicated buzzer from the AFM PCI card cannot be monitored nor controlled from the operative system command console, since it is a different buzzer than the one in-built in the motherboard. Therefore, the workaround was to physically "listen" to this beep by connecting a microphone module directly to the wires of the dedicated buzzer, to look for the millivolts change in the voltage signal. This is performed through the cable that appears from the bottom front of the PC unit in Fig. 2 that goes into a microphone module in the Arduino control unit visible in Fig. 4 and 5, in which the microphone itself was removed and replaced by a 4.7 kΩ resistor. Moreover, the dedicated buzzer had an unusual way of working in which both wires were at 5 V in the idle state. This was solved by decoupling the DC signal through a 100 nF ceramic capacitor to listen only to the AC signal during the beep. Since each AFM will be different, even for different models of the same manufacturer, it is not worth to describe the particular installation of the gears that motorize the manual control, secured in our case by double side adhesive tape. We point the reader to Fig. 2 to get an idea of how to mount and adapt the motorization to their particular AFMs.

Operation instructions
To get started, the user switches on the AFM PC which powers the Arduino Leonardo through the USB port, and the control unit turns on with the initial screen, as shown in Fig. 6 and in the video provided in the additional repository [1]. Next, the user switches on the 12 V power supply that provides the power to the stepper motors. This separation from the rest of the power supply can be useful to implement a panic button for the motorization. In this condition, the motorization is ready and the user can move freely over the sample with the joystick. Depending on the planned work, if the user wants to acquire a few images manually, it is advisable to use the AFM software Nanoscope Version 6 or above, since it is more user friendly. However, in that version not all the required keyboard shortcuts are available, and therefore in order to use the automated acquisition the user needs to open the Nanoscope Version 5 or below. Moreover, the user needs to move the joystick towards the right to account for the backlash present in the AFM threaded rods. This backlash results in limitations discussed in the following sections, and that is worth of trying to mechanically fix it in the future. The movement is to the right because this is the direction in which the automation will move the motors between image acquisitions, and this first movement will make sure the backlash is not a problem regarding the accuracy of the positioning. This is also the reason that for now the automation is only available to acquire images in one column, as there is no possibility to change directions without backlash. Next, the AFM is calibrated as usual, and once the AFM is ready to work with the substrate in place the user will start acquiring an image to make sure all parameters are fine, since these will be used for all further image acquisitions. Once the image is acquired and the tip is withdrawn from the sample, the user must press button 8 on the control unit to start selecting the automation parameters as shown in Fig. 6 and in the video provided in the additional repository [1], such as the number of images, spacing between acquisitions in terms of micrometers, target amplitude setpoint and acquisition time for each image. The later can be calculated from the parameters set in the AFM software, e.g. 512 lines at 1 Hz will take a total of 512 s (this parameter is usually set as powers of 2). Once everything is set within the control unit, the Arduino Leonardo will start to control the AFM, autotuning the tip, approaching the sample until it registers the "beep", then waiting the set acquisition time and moving to the next position to repeat the process and acquire the next image, repeating it as many times as programmed.

Validation and characterization
The original AFM positioning system already presents a dispersion in X and Y values even when we measure at the same place, engaging and withdrawing the AFM tip between consecutive image acquisitions. In order to characterize these inherent displacements, we acquired 3 consecutive 32 × 32 μm 2 images at the same place of a polymeric microgel nanostructure deposited on a silicon substrate, following the protocol described in a previous publication [6] (see Fig. 7). This allowed us to identify single microgels and measure their displacement with sub-micron accuracy between consecutive images. This resulted in displacements ΔX = 0.32 ± 0.15 μm and ΔY = 0.42 ± 0.18 μm. Therefore, this sets a lower boundary for the repeatability of our positioning system, in the range of ≃ 0.5 μm.
In order to calibrate the displacement of the individual micro-steps, first a microscope calibration slide with square features was used as a substrate. The motor was moved until the feature disappeared from the optical image. This resulted in an estimated 2.4 mm per full round of the big gear. In order to obtain the estimated μm per micro-step we divided the 2.4 mm by 200 ⋅ 16 micro-steps, and multiplied for the 11/45 gear reduction factor, since we operate the small gear. This was used as a starting approximation of ≃ 0.18 μm per micro-step. It is worth noting that for this measurement we first displaced the motor in the measuring direction to account for the backlash present in the AFM threaded screws. The backlash, over 100 μm when switching directions of the motor, is a problem in terms of accuracy in positioning if the joystick is moved in different directions each time, but as long as the motors move in the same direction after a few first movements that correct the backlash, the rest of movements are accurate as discussed. Next, we used an AFM tip that we characterized in an optical microscope with a 50x objective (WLCM, PLμ Confocal Imaging Profiler, Sensofar) resulting in a width of 37.9 ± 0.1 μm (see Fig. 8a). Then, we placed the tip in our AFM and focused it and displaced the stage 32 μm and observed how much it displaced over the optical camera images (see Fig. 8a), this resulted in 34 ± 1 μm. Given the low quality of the AFM optical camera, we decided to acquire AFM images of the same sample in Fig. 7. Therefore, by following the Operation instructions described before, we automatically acquired eight 32 × 32 μm 2 images with a set X-displacement between images of 16 μm, an amplitude setpoint of 0.9 V, and 512 s acquisition time for each image (see Fig. 8b showing 4 of the 8 acquired images). Thanks to this automation, an arbitrary number of images can be acquired in an unattended way. As described above, we identified single microgels in the AFM images and quantified how much they moved compared to the pre-set 16 μm displacement in X (squared regions of same color between consecutive AFM images in Fig. 8b correspond to same regions of the substrate), resulting in ΔX = 17.8 ± 0.4 μm and ΔY = 0.22 ± 0.16 μm. Thus, the displacement in Y was within the inherent positioning error of the AFM as discussed above, and the displacement in X was only slightly above the initial guess, 17.8 ± 0.4 μm instead of 16 μm.
With this information, we corrected our initial calibration as 0.18 μm ⋅ 17.8 μm/16 μm = 0.20 μm per micro-step, and expected a minimum error in positioning between images in the range of ≃ 0.5 μm, inherent to the AFM original positioning system. By acquiring a new set of 8 images (not shown) we found that the displacement between images was reduced to ΔX = 0.7 ± 0.4 μm, compatible with the inherent displacements of the AFM described above. It is worth noting that this is a remarkable positioning accuracy for such an inexpensive setup.
Possible mechanical improvements would include mechanically upgrading the original AFM positioning system to reduce the significant backlash present in the system, over 100 μm when switching directions of the motor. Currently, we restrict this source of inaccuracy by moving the motors in one way during automated acquisition as described before. Reducing the backlash by other mechanical means would allow automated acquisitions in two dimensions without restrictions. This would be a very important advantage when carrying out consecutive measurements requiring large area characterizations. An easier upgrade would be including Wi-Fi to the Arduino to operate the unit remotely. In this sense, the Arduino platform allows for many possible upgrades with little extra effort. Fig. 7. AFM images of a polymeric microgel nanostructure deposited on a silicon substrate acquired sequentially on the same region to show the inherent displacements of the AFM. These displacements are easy to spot by eye at the corners of the images where differences between images are more apparent.